<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>多语言旅行助手</title>
    <link rel="stylesheet" href="style.css">
    <base href="/">
</head>
<body>
    <!-- 顶部导航栏 -->
    <header>
        <h1>多语言旅行助手</h1>
        <nav>
            <ul>
                <li><a href="index.html" class="active">首页</a></li>
                <li><a href="learning.html">学习中心</a></li>
                <li><a href="translation.html">翻译</a></li>
                <li><a href="culture.html">文化知识库</a></li>
                <li><a href="map.html">离线地图</a></li>
                <li><a href="travel-plan.html">旅行计划</a></li>
                <li><a href="offline-content.html">离线内容</a></li>
                <li><a href="profile.html">个人资料</a></li>
                <li><a href="settings.html">设置</a></li>
            </ul>
        </nav>
    </header>

    <!-- 侧边导航栏 -->
    <aside class="side-nav">
        <ul>
            <li>
                <a href="index.html" class="active">
                    <img src="images/home.svg" alt="首页图标">
                    <span>首页</span>
                </a>
            </li>
            <li>
                <a href="learning.html">
                    <img src="images/book-open-bold.svg" alt="学习图标">
                    <span>学习</span>
                </a>
            </li>
            <li>
                <a href="translation.html">
                    <img src="images/vector_25_310.svg" alt="翻译图标">
                    <span>翻译</span>
                </a>
            </li>
            <li>
                <a href="culture.html">
                    <img src="images/globe-bold.svg" alt="文化图标">
                    <span>文化</span>
                </a>
            </li>
            <li>
                <a href="map.html">
                    <img src="images/vector_25_317.svg" alt="地图图标">
                    <span>地图</span>
                </a>
            </li>
            <li>
                <a href="offline-content.html">
                    <img src="images/vector_25_324.svg" alt="离线内容图标">
                    <span>离线</span>
                </a>
            </li>
            <li>
                <a href="settings.html">
                    <img src="images/vector_25_331.svg" alt="设置图标">
                    <span>设置</span>
                </a>
            </li>
        </ul>
    </aside>

    <main>
        <section class="hero">
            <h2>探索世界，无语言障碍</h2>
            <p>多语言旅行助手帮助您在旅行中轻松应对语言挑战，了解当地文化，享受无忧旅程。</p>
            <div class="cta-buttons">
                <a href="learning.html" class="btn primary">开始学习</a>
                <a href="offline-content.html" class="btn secondary">下载离线内容</a>
            </div>
        </section>

        <section class="features">
            <h2>主要功能</h2>
            <div class="feature-grid">
                <div class="feature-card">
                    <h3>语言学习</h3>
                    <p>学习旅行目的地的常用短语、对话和词汇，提高语言技能。</p>
                    <a href="learning.html" class="btn small">开始学习</a>
                </div>
                <div class="feature-card">
                    <h3>实时翻译</h3>
                    <p>文本翻译和情境化翻译建议，帮助您更好地沟通。</p>
                    <a href="translation.html" class="btn small">立即翻译</a>
                </div>
                <div class="feature-card">
                    <h3>文化知识库</h3>
                    <p>了解目的地的历史、文化习俗和禁忌，尊重当地文化。</p>
                    <a href="culture.html" class="btn small">探索文化</a>
                </div>
                <div class="feature-card">
                    <h3>离线地图</h3>
                    <p>下载目的地地图，包含兴趣点和推荐路线，无需网络也能导航。</p>
                    <a href="map.html" class="btn small">查看地图</a>
                </div>
            </div>
        </section>

        <section class="destinations">
            <h2>热门目的地</h2>
            <div class="destination-grid" id="destination-grid">
                <!-- 目的地将通过JavaScript动态加载 -->
                <div class="loading">加载中...</div>
            </div>
        </section>
    </main>

    <footer>
        <p>&copy; 2025 多语言旅行助手 | 版本 1.0</p>
    </footer>

    <script src="script.js"></script>
    <script>
        // 获取可用目的地
        fetch('/api/available_destinations')
            .then(response => response.json())
            .then(data => {
                const destinationGrid = document.getElementById('destination-grid');
                destinationGrid.innerHTML = ''; // 清除加载提示
                
                // 遍历目的地并创建卡片
                Object.entries(data.destinations).forEach(([key, destination]) => {
                    const card = document.createElement('div');
                    card.className = 'destination-card';
                    
                    // 如果目的地不可用，添加不可用标记
                    if (!destination.available) {
                        card.classList.add('coming-soon');
                    }
                    
                    // 创建卡片内容
                    card.innerHTML = `
                        <h3>${destination.name}</h3>
                        <p>${destination.country}</p>
                        ${destination.available 
                            ? `<div class="package-info">
                                <span>语言包: ${destination.languageSize}MB</span>
                                <span>地图包: ${destination.mapSize}MB</span>
                                <span>文化包: ${destination.cultureSize}MB</span>
                               </div>
                               <a href="offline-content.html?destination=${key}" class="btn small">下载内容</a>`
                            : `<div class="eta">即将推出: ${destination.eta}</div>`
                        }
                    `;
                    
                    destinationGrid.appendChild(card);
                });
            })
            .catch(error => {
                console.error('获取目的地失败:', error);
                const destinationGrid = document.getElementById('destination-grid');
                destinationGrid.innerHTML = '<div class="error">加载目的地失败，请稍后再试。</div>';
            });
    </script>
</body>
</html>